const http = require('http');
const fs = require('fs');


function downloadImage(url, filename) {
    const file = fs.createWriteStream(filename);
    http.get(url, (res) => {
        res.pipe(file);
        console.log(`${filename} 下载完成`);
    });
}

downloadImage('http://gw.alicdn.com/imgextra/i4/O1CN01a71ilU1T2RCTvUXDY_!!6000000002324-0-tps-846-472.jpg', 'image.jpg');